package com.cby.ssm.service.impl;

import com.cby.ssm.dao.Role_PermissionDao;
import com.cby.ssm.entity.Role_PermissionEntity;
import com.cby.ssm.service.Role_PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 13296 on 2017/7/24.
 */
@Service
public class Role_PermissionServiceImpl implements Role_PermissionService {
    @Autowired
    Role_PermissionDao rpdao;

    @Override
    public List<Role_PermissionEntity> SearchAllPermissionsByRoleId(String roleId) throws Exception {
        List<Role_PermissionEntity> list = rpdao.selectAllPermissionByRoleId(roleId);
        return list;
    }

    @Override
    public boolean deletePermissionsOfRoleId(String roleId) throws Exception {
        rpdao.delete("roleId",roleId);
        return false;
    }

    @Override
    public void addPermissionOfRoleId(String roleId, String permissionId) throws Exception {
        Role_PermissionEntity rp = new Role_PermissionEntity(roleId,permissionId);
        rpdao.insert(rp);
    }
}
